package acwing_05;
import java.io.*;
import java.util.*;
public class _895_线性DP_最长上升子序列 {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	static int N = 100010;
	static int n;
	static int arr[] = new int[N];
	static int dp[] = new int[N];
	public static void main(String[] args) throws IOException {
		n = Integer.parseInt(br.readLine());
		st = new StringTokenizer(br.readLine());
		for(int i = 1; i <= n; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
		}
		
		for(int i = 1; i <= n; i++) {
			dp[i] = 1;
			for(int j = 2; j < i; j++) {
				if(arr[i] > arr[j]) {
					// 如果第i个数大于前i-1个数就取前i-1结尾的子序列长度+1
					/* 
					 * 当遇到 arr[i] > arr[j] 但是dp[i] > dp[j]+1，
					 * 说明在arr[j]之后有一个dp[j]加过当前序列的1，则依旧取当前dp[i]的值，
					 * 后续循环遍历到对应的dp[j]时 dp[j]+1 > dp[i]，就会取dp[j]+1的值
					 * */
					dp[i] = Math.max(dp[i], dp[j] + 1);
				}
			}
		}
		
		int res = 0;
		for(int i = 1; i <= n; i++) {
			res = Math.max(res, dp[i]);
		}
		
		System.out.println(res);
		
	}
}
